// components/pull-down/index.js
const app = getApp()

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    dataList: {
      type: Array,
      value: [],
      observer: function (val) {
        this.setData({
          aJumpRopecAtions: val
        })
      }
    },
    hide: {
      type: Boolean,
      value: false,
      observer: function (val) {
        if (!val) {

          this.didClickHiden()
        }

      }
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    aJumpRopecAtions: [],
    isShow: false
  },
  created() {


  },
  mounted() {


  },


  /**
   * 组件的方法列表
   */
  methods: {
    didClickHiden() {
      this.setData({
        isShow: false,
      })

      for (let i = 0; i < this.data.aJumpRopecAtions.length; i++) {
        this.data.aJumpRopecAtions[i].isSelect = false;
      }
      this.setData({
        aJumpRopecAtions: this.data.aJumpRopecAtions
      })

    },
    didClickTitle(e) {

      let index = e.currentTarget.dataset.index;
      this.changeIndex(index, 0)

      this.setData({
        isShow: !this.data.isShow,
      })
    },
    changeIndex(index, subIndex) {

      let data = this.data.aJumpRopecAtions[index]
      data.isSelect = data.isSelect ? false : true;
      data.select = data.list[subIndex]
      this.data.aJumpRopecAtions[index] = data
      this.setData({
        aJumpRopecAtions: this.data.aJumpRopecAtions
      })

    },

    didClickSubTitle(e) {
      let dataset = e.currentTarget.dataset;
      let index = dataset.index
      let subIndex = dataset.data;

      this.changeIndex(index, subIndex)

      this.setData({
        pageNo: 1,
        time: this.data.aJumpRopecAtions[1].select.id,
        type: this.data.aJumpRopecAtions[0].select.id,
      })
      this.triggerEvent("didClickPull", this.data.aJumpRopecAtions);
      console.log('筛选数据获取', this.data.aJumpRopecAtions)
      this.setData({
        isShow: false,
      })
    },
  }
})